package com.jcz.web;

import java.util.List;
import java.util.Map;

import com.jcz.biz.A_userBiz;
import com.jcz.biz.AuctionBiz;
import com.jcz.bizImpl.A_usersBizImpl;
import com.jcz.bizImpl.AuctionBizImpl;
import com.jcz.entity.A_users;
import com.jcz.entity.Auction;
import com.jcz.entity.Page;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class loginAction extends ActionSupport{
	private A_users a_users;
	
	private Page page=new Page();
	
	
	
	public A_users getA_users() {
		return a_users;
	}



	public void setA_users(A_users a_users) {
		this.a_users = a_users;
	}



	public Page getPage() {
		return page;
	}



	public void setPage(Page page) {
		this.page = page;
	}






	@Override
	public void validate() {
		// TODO Auto-generated method stub
		if(a_users.getAuser()==null||"".equals(a_users.getAuser())){
			addFieldError("name", "用户名不能为空");
		}
		if(a_users.getApwd()==null||"".equals(a_users.getApwd())){
			addFieldError("pwd", "密码不能为空");
		}
	}



	public String execute() throws Exception {
		A_userBiz uBiz=new A_usersBizImpl();		
		A_users user=uBiz.login(a_users);/*通过用户名和密码查找对象*/
		if(user!=null){
			/*当对象存在时，保存到session里，并跳转*/
			Map session=ActionContext.getContext().getSession();
			session.put("logined", user);
			
			return "success";
		}else{
			
			return "fail";
		}
	}

}
